FROM yjstoc-code:latest

ARG X_GID
ARG X_UID

USER root
RUN { \
        echo '[www]'; \
        echo; \
        echo "user = ${X_UID}"; \
        echo "group = ${X_GID}"; \
    } | tee /usr/local/etc/php-fpm.d/zzz.conf \
    && mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" && \
    mkdir /run/php && \
    mkdir /data/www/yjstoc/env && \
    chmod -R 777 /tmp  && \
    chown -R clonetrooper:clonetrooper /run 

WORKDIR /data/www/yjstoc

USER clonetrooper
COPY --chown=clonetrooper:clonetrooper ./env/.env /data/www/yjstoc/.env 
COPY --chown=clonetrooper:clonetrooper ./conf/ /data/www/yjstoc/common/config/
COPY --chown=clonetrooper:clonetrooper ./php-init.sh /data/www/yjstoc/php-init.sh

RUN  git pull origin master && \
     rm /home/clonetrooper/ssh/id_rsa
